<template>
  <basic-container>
    <el-form :inline="true" :model="query" class="demo-form-inline">
      <el-row>
        <el-form-item label="项目编号:">
          <el-input v-model="query.projectCode" clearable placeholder="项目编号" size="small"></el-input>
        </el-form-item>
        <el-form-item label="项目名称:">
          <el-input v-model="query.projectName" clearable placeholder="项目名称"></el-input>
        </el-form-item>
      </el-row>
      <el-row>
        <el-form-item>
          <el-button size="small" type="primary" icon="el-icon-search" @click="onSearch" :loading="loading">搜索
          </el-button>
          <el-button size="small" icon="el-icon-delete" @click="searchReset" :loading="loading">清空</el-button>
        </el-form-item>
      </el-row>
    </el-form>
        <div class="btn-operate">
          <el-button @click="addRectifySummary" type="primary" size="small" icon="el-icon-plus">
            新增
          </el-button>
        </div>
    <el-table v-loading="loading" :data="data" border
              highlight-current-row @cell-click="handleCellClick" style="width: 100%">
      <el-table-column prop="projectCode" label="项目编号"></el-table-column>
      <el-table-column prop="projectName" label="项目名称"></el-table-column>
      <el-table-column prop="pendingCount" label="已整改">
      </el-table-column>
      <el-table-column prop="solvedCount" label="未整改">
      </el-table-column>
      <el-table-column prop="pendingCount" label="已销号">
      </el-table-column>
      <el-table-column prop="solvedCount" label="未销号">
      </el-table-column>
<!--      <el-table-column label="操作" width="170">-->
<!--        <template slot-scope="scope">-->
<!--          <el-button type="text" size="small" icon="el-icon-view" @click="showViewBox(scope.row)">查看</el-button>-->
<!--          <el-button type="text" size="small" icon="el-icon-edit" @click="showEditBox(scope.row)">编辑</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="sizeChange"
        @current-change="currentChange"
        :current-page="page.currentPage"
        :page-sizes="[10, 20, 30, 40 ,50 ,100]"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total">
      </el-pagination>
    </div>

    <table-form ref="rectifySummary" @cancelDialog="closeRectifySummaryDialog"></table-form>
  </basic-container>
</template>
<script>
import TableForm from "@/components/form/rectifySummaryForm.vue";
import TaskAuditDialog from "@/components/act/TaskAuditDialog.vue";
import {fetchList, getRectifyReport, rejectSubmit, approveSubmit} from "@/api/adis/track/rectifyReprot";
import {mapGetters} from "vuex";
import RectifyReportView from "@/components/actForm/RectifyReportView.vue";
import WebDocument from "@/components/form/webDocument.vue";

export default {
  components: {WebDocument, RectifyReportView, TaskAuditDialog, TableForm},
  computed:{
    ...mapGetters(["permissions"])
  },
  dictTypes: ['audit_type_1_sub','ectification_situation'],
  data(){
    return{
      query:{},
      form:{},
      data:[],
      tableData:[],
      loading:false,
      isView:false,
      viewBox:false,
      auditBox:false,
      page:[
        {
          total:1,
          currentPage:10
        }
      ],
      formTitle: '',
      Authorization: '',
    }
  },
  created() {
    this.onLoad(this.page);
    this.Authorization = 'Bearer ' + this.$store.getters.access_token
  },
  methods:{
    addRectifySummary(row){
      this.$nextTick(() => {
        this.$refs.rectifySummary.init(row,true);
      })
    },
    closeRectifySummaryDialog(){
      this.onLoad(this.page);
    },
    onSearch(){
      this.page.current = 1;
      this.onLoad(this.page);
    },
    searchReset() {
      this.query = {};
      this.page.current = 1;
      this.onLoad(this.page)
    },
    sizeChange(size) {
      this.page.size = size;
      this.onLoad(this.page);
    },
    currentChange(current) {
      this.page.current = current;
      this.onLoad(this.page);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      // this.query.reportStatus = '初稿';
      fetchList(Object.assign(params, this.query, page)).then(res => {
        this.loading = false;
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
      }, () => {
        this.loading = false;
      });
    },
    // handlePreview (file) {
    //   // console.log(file.url);
    //   const a = document.createElement('a');
    //   let url = file.url ? file.url : file.response.data.url;
    //   console.log(url);      // let fileName = '你想要的文件名.docx'; // 这里设置你想要的文件名，包括扩展名
    //   a.setAttribute('download', file.name);
    //   a.setAttribute('href', url);
    //   a.click();
    //   // window.open(file.url ? file.url : file.response.data.url)
    // },
    // wordFileHandle(e) {
    //   this.$set(this.form, "wordFile", e.wordFile);
    //   this.$set(this.form, "reportId", e.id);
    // },
  }
}
</script>

